package designpattern.strategy.now.discount;

import designpattern.strategy.now.discount.impl.Discount6;
import designpattern.strategy.now.discount.impl.Discount85;
import designpattern.strategy.now.discount.impl.NoDiscount;
import designpattern.strategy.now.discount.impl.Return5;

/**
 * @author zhaoqiankun
 * @since 2021-12-27 1:07
 * 重构后：
 * 增加新的优惠⽅案时只需要继承抽象策略类即可，修改优惠⽅案时不需要修改BuyGoods类
 * 源码；
 * 代码复⽤也变得简单，直接复⽤某⼀个具体策略类即可；
 * BuyGoods类的calculate变得简洁，没有了原本的if分⽀；
 */
public class Test {
    public static void main(String[] args) {
        BuyGoods buyGoods1 = new BuyGoods("Java编程思想", 99.00, new
                Discount85());
        buyGoods1.calculate();
        BuyGoods buyGoods2 = new BuyGoods("罗技⿏标", 66, new Discount6());
        buyGoods2.calculate();
        BuyGoods buyGoods3 = new BuyGoods("苹果笔记本", 15000.00, new
                Return5());
        buyGoods3.calculate();
        BuyGoods buyGoods4 = new BuyGoods("佳能相机", 1900, new
                NoDiscount());
        buyGoods4.calculate();
    }
}
